<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="icon" href="../img/asset-favico.ico">
        <title>添加联系人信息</title>
        <link rel="stylesheet" href="../css/page-health-login.css" />
        <link rel="stylesheet" href="../plugins/elementui/index.css" />
        <script src="../plugins/jquery/dist/jquery.min.js"></script>
        <script src="../plugins/healthmobile.js"></script>
        <script src="../plugins/vue/vue.js"></script>
        <script src="../plugins/vue/axios-0.18.0.js"></script>
        <script src="../plugins/elementui/index.js"></script>
        <script>
            let id = getUrlParam("id");
        </script>
    </head>
    <body data-spy="scroll" data-target="#myNavbar" data-offset="150">
        <div class="app" id="app">
            <!-- 页面头部 -->
            <div class="top-header">
                <span class="f-left"><i class="icon-back"></i></span>
                <span class="center">传智健康</span>
                <span class="f-right"><i class="icon-more"></i></span>
            </div>
            <div style="margin-left: 20px">添加联系人信息</div>
            <!-- 页面内容 -->
            <div class="contentBox">
                <div class="login">
                    <form id='login-form'>
                        <div class="input-row">
                            <label>姓名</label>
                                <input v-model="relativeInfo.name" id='account' type="text" placeholder="请输入姓名">
                        </div>


                            <label class="radio-title">性别</label>

                          <div class="input-row">

                                <div class="cell">
                                    <input v-model="relativeInfo.sex" type="radio" name="sex" value="1" checked>

                                    <span>男</span>
                               <!-- </div>
                                <div class="cell">-->
                                    <input v-model="relativeInfo.sex"  type="radio" name="sex" value="2">

                                    <span>女</span>
                                </div>


                            </div>

                        <div class="input-row">
                            <label>身份证号</label>
                            <input v-model="relativeInfo.idCard" type="text" class="input-clear" placeholder="请输入身份证号">
                        </div>
                        <div class="input-row" style="font-size: 12px">
                            <input type="checkbox" checked>
                            阅读并同意《传智健康用户协议》《传智健康隐私条款》
                        </div>
                        <div class="btn yes-btn"><a @click="addRelative()" href="#">提交</a></div>
                    </form>
                </div>
            </div>
        </div>
    </body>
    <script>
        var vue = new Vue({
            el:'#app',
            data:{
                relativeInfo:{}
            },

            methods:{
                addRelative() {
                    //校验身份证号格式
                    if(!checkIdCard(this.relativeInfo.idCard)){
                        this.$message.error('身份证号码输入错误，请重新输入');
                        return ;
                    }
                    let token = localStorage.getItem("token");
                    this.relativeInfo.token=token;
                    axios.post("/relative/add.do",this.relativeInfo).then((result) => {

                        if(result.data.flag) {
                            //添加成功，跳转到预约成功页面
                             window.location.href="orderInfo.html?id="+id;
                            this.$message({
                                message: result.data.message,
                                type:"success"
                            })
                        }else {
                            this.$message({
                                message: result.data.message,
                                type:"error"
                            })
                        }
                    });

                },
            }
        });
    </script>
</html>